#include "WayPoint.h"


WayPoint::WayPoint(void)
{
	 _nextWaypoint = NULL;
}


WayPoint::~WayPoint(void)
{
}

bool WayPoint::initWithTheGame( GameScene* game, cocos2d::CCPoint location )
{
	_myPosition = location;
	theGame = game;

	INIT_UP
		CC_BREAK_IF(!CCNode::create());
		this->setPosition(CCPointZero);
		theGame->addChild(this);

	INIT_DOWN
}

WayPoint* WayPoint::createWithObj( GameScene* game, cocos2d::CCPoint location )
{
	WayPoint *pRet = new WayPoint();
	if (pRet && pRet->initWithTheGame(game, location))
	{
		return pRet;
	}
	else
	{
		delete pRet;
		pRet = NULL;
		return NULL;
	}
}

void WayPoint::draw( void )
{
#ifdef COCOS2D_DEBUG
	ccDrawColor4F(0, 255, 0, 255);
	ccDrawCircle(_myPosition, 6, 360, 30, false);
	ccDrawCircle(_myPosition, 2, 360, 30, false);

	if (_nextWaypoint)
	{
		ccDrawLine(_myPosition, _nextWaypoint->_myPosition);
	}
#endif

	CCNode::draw();
}
